package com.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class UserProxy {

	private Object target;

	public UserProxy(Object target) {
		this.target = target;
	}

	public Object getProxy() {

		Object proxy = Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(),
				new InvocationHandler() {
					@Override
					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
						Object ob = null;
						if ("hello".equals(method.getName())) {
							ob = method.invoke(target, args);
						}
						return ob;
					}
				});

		return proxy;

	}
}
